package org.vudroid.pdfdroid.codec;

import org.vudroid.core.codec.CodecDocument;
import org.vudroid.core.codec.CodecPage;

/* loaded from: classes2.dex */
public class PdfDocument implements CodecDocument {
    private static final int FITZMEMORY = 524288;
    private long docHandle;

    private static native void free(long j);

    private static native int getPageCount(long j);

    private static native long open(int i, String str, String str2);

    private PdfDocument(long j) {
        this.docHandle = j;
    }

    @Override // org.vudroid.core.codec.CodecDocument
    public CodecPage getPage(int i) {
        return PdfPage.createPage(this.docHandle, i + 1);
    }

    @Override // org.vudroid.core.codec.CodecDocument
    public int getPageCount() {
        return getPageCount(this.docHandle);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static PdfDocument openDocument(String str, String str2) {
        return new PdfDocument(open(524288, str, str2));
    }

    protected void finalize() throws Throwable {
        recycle();
        super.finalize();
    }

    @Override // org.vudroid.core.codec.CodecDocument
    public synchronized void recycle() {
        if (this.docHandle != 0) {
            free(this.docHandle);
            this.docHandle = 0L;
        }
    }
}
